{% extends 'base.html' %}

{% block page-main %}
    <div class="container-fluid">
        <div class="row">
            {% include 'manage_nav.html' %}
            <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
                <h1 class="page-header">所有分类</h1>

                <div class="panel panel-primary">
                    <!-- Default panel contents -->
                    <div class="panel-heading">所有分类</div>
                    <div class="panel-body">
                        <div class="row" style="margin-bottom: 15px">
                            <div class="pull-right">
                                <a href="/bigcategory_add/" class="btn btn-success">添加分类</a>
                                <a href="/subcategory_add/" class="btn btn-success">添加子分类</a>
                            </div>

                        </div><!-- /.row -->

                        <table class="table table-bordered">
                            <thead>
                            <tr>
                                <th>序号</th>
                                <th>分类名称</th>
                                <th>子分类</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            {% for bcategory in all_bcategories %}
                                <tr>
                                    <td>{{ forloop.counter }}</td>
                                    <td>{{ bcategory.title }}</td>
                                    <td>
                                        {% for categories in bcategory.categories.all %}
                                            {{ categories.subcategory.title }}/
                                        {% endfor %}
                                    </td>
                                    <td>
                                        <a class="btn btn-danger" href="/category_del/?id={{ bcategory.pk }}">删除</a>
                                        <a class="btn btn-info" href="/category_edit/?id={{ bcategory.pk }}">编辑</a>
                                    </td>
                                </tr>
                            {% endfor %}
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
{% endblock %}